## Attention This library should be completely independent of the Simulation
## 			 project so that it can be included in different programs.

#include ../make_includes.mk


CPPFILES = $(shell ls *.cpp)
HPPFILES = $(shell ls *.hpp)
OFILES   = $(CPPFILES:%.cpp=%.o)
CC       = @CGCC@

CFLAGS :=-Wall -Wextra `@prefix@/bin/mylibs-config --cflags`

ifdef USE_GCOV
	#ifeq (echo "$CFLAGS" | grep "-fprofile-arcs -ftest-coverage",)
		CFLAGS += -fprofile-arcs -ftest-coverage
	#endif
endif

libShape.a: $(OFILES)
	ar -r libShape.a $(OFILES)

doc:
	@echo "================= Building Documentation ===================="
	doxygen Doxyfile > doxygen.log
	@echo "See doxygen.log for further information"

install: libShape.a
	@echo "================= Installing Shape ======================="
	@echo "Installing into  @prefix@/stow/mylibs/"
	@echo  @prefix@/stow/mylibs/ > prefix.log

	mkdir -p @prefix@/stow/mylibs/bin
	mkdir -p @prefix@/stow/mylibs/lib
	mkdir -p @prefix@/stow/mylibs/include/Shape;

	install --mode=755 Shape-config @prefix@/stow/mylibs/bin/Shape-config

	install --mode=744 *.a @prefix@/stow/mylibs/lib/;
	install --mode=744 Shape.hpp @prefix@/stow/mylibs/include/Shape.hpp
	install --mode=744 *.hpp @prefix@/stow/mylibs/include/Shape/;
	@echo "=============================================================="

uninstall:
	cd @prefix@/stow/mylibs/include/ && rm -rfv Shape Shape.hpp && cd -;
	cd @prefix@/stow/mylibs/lib/ && rm -fv libShape.a && cd -;
	cd @prefix@/stow/mylibs/bin/ && rm -fv Shape-config && cd -;

%.o: %.cpp %.hpp
	$(CC) $(CFLAGS) $(OPT) -c $<

clean:
	@echo "======================== Clean Up ==========================="
	rm -rif *.o *.gcov *.gcno *.gcda doxygen.log libShape.a
	make -C Testing clean
	rm -rif doc latex
